// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import ZkTable from 'vue-table-with-tree-grid'



import axios from 'axios'


// 导入编辑器
import VueQuillEditor from 'vue-quill-editor'

// require styles  导入编辑器样式
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'

// 全局挂载
Vue.use(VueQuillEditor)


Vue.prototype.$http = axios
// 配置请求的路由
// axios.defaults.baseURL = "https://www.liulongbin.top:8888/api/private/v1/"
axios.defaults.baseURL = "http://127.0.0.1:8888/api/private/v1/"

axios.interceptors.request.use(config => {
    // console.log(config) //添加token发送请求
    config.headers.Authorization = window.sessionStorage.getItem('token')
    // 必须在最后return 
    return config
})



//  第三方图标导入样式表

// 引入全局样式表
import './assets/css/global.css'

Vue.config.productionTip = false

Vue.use(ElementUI);
Vue.use(ZkTable)

// 全局过滤器
// 处理时间格式
Vue.filter('dateFormat', function (originVal) {
    const dt = new Date(originVal)
    const y = dt.getFullYear()
    const m = (dt.getMonth() + 1 + '').padStart(2, '0')
    const d = (dt.getDay() + 1 + '').padStart(2, '0')


    const hh = (dt.getHours() + 1 + '').padStart(2, '0')
    const mm = (dt.getMinutes() + 1 + '').padStart(2, '0')
    const ss = (dt.getSeconds() + 1 + '').padStart(2, '0')

    return `${y}-${m}-${d} ${hh}:${mm}:${ss}`

})



/* eslint-disable no-new */
new Vue({
    el: '#app',
    router,
    components: { App },
    template: '<App/>'
})
